package com.cherry.utils;

import java.text.SimpleDateFormat;
import java.util.Calendar;

/**
 * @create 2020-09-02 10:21 下午
 * @function:
 **/
public class DateUtil {
    public static String getTime(int num) {
        // 根据当前时间，计算第一场的时间
        Calendar c = Calendar.getInstance();
        // 获取当前的小时
        int hour = c.get(Calendar.HOUR_OF_DAY);
        if (hour % 2 != 0) {
            hour = hour -1;
        }
        c.set(Calendar.HOUR_OF_DAY,hour + num * 2);
        c.set(Calendar.MINUTE,0);
        c.set(Calendar.SECOND,0);
        c.set(Calendar.MILLISECOND,0);

        return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(c.getTime());
    }
}
